<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库：https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库：https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------

namespace app\index\controller;

use function PHPSTORM_META\type;
use think\admin\Controller;


/**
 * Class Index
 * @package app\index\controller
 */
class Index extends BaseController
{

    public static $news_category_id = 15;   //行业动态
    public static $policy_category_id = 22; //法律法规
    public static $product_category_id = 28; //产品设备
    public static $edu_category_id = 16; //培训教育
    public static $aboutus_notice_category_id = 19; //通知公告
    public static $aboutus_news_category_id = 30; //协会动态
    public static $carousel_category_id = 14; //轮播图片
    /**
     * 首页显示 3行内容
     * 第一行：协会工作（通知公告，协会动态），教育培训
     * 第二行：行业动态，政策法规
     * 第三行：产品介绍
     */
    public function index()
    {
        $this->title = '首页';

        $this->member = array("president"=>120,"vpresident"=>200,"director"=>280,"member"=>620);
        $this->carousel = array(
            "info" => $this->_get_category(self::$carousel_category_id),
            "list" => $this->_get_category_articles(self::$carousel_category_id,0,4),
        );
        $this->carousel2 = array(
            "info" => $this->_get_category(self::$aboutus_news_category_id),
            "list" => $this->_get_category_articles(self::$aboutus_news_category_id,0,5),
        );
        $this->edu = array(
            "info" => $this->_get_category(self::$edu_category_id),
            "list" => $this->_get_category_articles(self::$edu_category_id,0,8),
        );
        $this->news = array(
            "info" => $this->_get_category(self::$news_category_id),
            "list" => $this->_get_category_articles(self::$news_category_id,0,3),
        );
        $this->policy = array(
            "info" => $this->_get_category(self::$policy_category_id),
            "list" => $this->_get_category_articles(self::$policy_category_id,0,10),
        );
        $this->product = array(
            "info" => ["title"=>"产品设施"],
            "list" => $this->app->db->name("CmsQiyeProduct")->where(array("is_deleted"=>0))->order("id desc")->limit(0,4)->select()->toArray(),
        );

        $about_notice = $this->_get_category(self::$aboutus_notice_category_id);
        $about_notice['list'] = $this->_get_category_articles(self::$aboutus_notice_category_id,0,8);
        $about_news = $this->_get_category(self::$aboutus_news_category_id);
        $about_news['list'] = $this->_get_category_articles(self::$aboutus_news_category_id,0,8);
        $this->aboutus = [$about_notice, $about_news];

        $this->_get_nav_menus();
        $this->_system();
        $this->fetch();
    }

    public function demo1()
    {
        $this->title = '首页样式1';
        $this->fetch();
    }

    public function demo2()
    {
        $this->title = '首页样式2';
        $this->fetch();
    }

    public function demo3()
    {
        $this->title = '首页样式2';
        $this->fetch();
    }

    public function json(){
        $stu = array(
            "name" => "figol",
            "age" => 31,
        );
        $this->success($stu);
    }

}